<?php
/* FILE: process_search_items.php
 * DESCRIPTION: Process called when the search button is pressed on collection_item_list.php
 * POST DATA: crate, iurl, attr0-attr9
 * GET DATA: cname (collection_name)
 */ 
	session_start();

	include('config.inc');

	//Get all POST variables
	$sortby = $_GET['sb'];
	$collection = $_GET['cname'];
	$url = urlencode(trim($_POST['iurl']));
	$attr = array (
		urlencode(trim($_POST['attr0'])),
		urlencode(trim($_POST['attr1'])),
		urlencode(trim($_POST['attr2'])),
		urlencode(trim($_POST['attr3'])),
		urlencode(trim($_POST['attr4'])),
		urlencode(trim($_POST['attr5'])),
		urlencode(trim($_POST['attr6'])),
		urlencode(trim($_POST['attr7'])),
		urlencode(trim($_POST['attr8'])),
		urlencode(trim($_POST['attr9']))
	);
	switch((string)$_POST['crate'])
	{
		case 'zero': $rating = "0"; break;
		case 'one': $rating = "1"; break;
		case 'two': $rating = "2"; break;
		case 'thr': $rating = "3"; break;
		case 'four': $rating = "4"; break;
		case 'five': $rating = "5"; break;
		default: $rating = ""; break;	//Rating not chosen to search by
	}
	
	//Send search criteria via URL
	header
	(
		'Location: collection_item_list.php?colname='.$collection
		. ($sortby != "" ? '&sb='.$sortby : '')
		. ($rating != "" ? '&ir='.$rating : '')
		. ($url != "" ? '&iu='.$url : '')
		. ($attr[0] != "" ? '&a0='.$attr[0] : '')
		. ($attr[1] != "" ? '&a1='.$attr[1] : '')
		. ($attr[2] != "" ? '&a2='.$attr[2] : '')
		. ($attr[3] != "" ? '&a3='.$attr[3] : '')
		. ($attr[4] != "" ? '&a4='.$attr[4] : '')
		. ($attr[5] != "" ? '&a5='.$attr[5] : '')
		. ($attr[6] != "" ? '&a6='.$attr[6] : '')
		. ($attr[7] != "" ? '&a7='.$attr[7] : '')
		. ($attr[8] != "" ? '&a8='.$attr[8] : '')
		. ($attr[9] != "" ? '&a9='.$attr[9] : '')
	);
	
?>